// Kony

#pragma once

#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"
#include "BaseWidgetController.generated.h"

//这个是总控制器 可以用于 玩家属性状态类（AttributeMenuWidgetController） 和 界面UI类OverlayWidgetController
//玩家等级等整数数据委托广播
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnPlayerStatChangedSignature, int32, NewValue);
//广播能力信息委托，用于广播技能能力信息
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FAbilityInfoSignature, const FBaseAbilityInfo&, Info);


class UAbilitySystemComponent;
class UAttributeSet;
class ABasePlayerController;
class ABasePlayerState;
class UBaseAbilitySystemComponent;
class UBaseAttributeSet;
class UAbilityInfo;

USTRUCT(BlueprintType)
struct FWidgetControllerParams
{
	GENERATED_BODY()
	// 默认构造函数
	FWidgetControllerParams(){}
	// 带参数的构造函数，用于初始化控件控制器所需的各个组件
	// @param PC 玩家控制器指针
	// @param PS 玩家状态指针
	// @param ASC 能力系统组件指针
	// @param AS 属性集指针
	FWidgetControllerParams(APlayerController* PC, APlayerState* PS, UAbilitySystemComponent* ASC, UAttributeSet* AS)
	: PlayerController(PC),PlayerState(PS),AbilitySystemComponent(ASC),AttributeSet(AS){}

	// 可编辑的玩家控制器指针，在蓝图中可见并可设置
	UPROPERTY(EditAnywhere,BlueprintReadOnly)
	TObjectPtr<APlayerController> PlayerController = nullptr;
	
	// 可编辑的玩家状态指针，在蓝图中可见并可设置
	UPROPERTY(EditAnywhere,BlueprintReadOnly)
	TObjectPtr<APlayerState> PlayerState= nullptr;

	// 可编辑的能力系统组件指针，在蓝图中可见并可设置
	UPROPERTY(EditAnywhere,BlueprintReadOnly)
	TObjectPtr<UAbilitySystemComponent> AbilitySystemComponent = nullptr;

	// 可编辑的属性集指针，在蓝图中可见并可设置
	UPROPERTY(EditAnywhere,BlueprintReadOnly)
	TObjectPtr<UAttributeSet> AttributeSet = nullptr;
	
};
/**
 * 用户控件控制器
 */
UCLASS()
class GASC_HUANLING_API UBaseWidgetController : public UObject
{
	GENERATED_BODY()
public:
	// 设置控件控制器参数
	// @param WCParams 控件控制器参数结构体
	UFUNCTION(BlueprintCallable)
	void SetWidgetControllerParams(const FWidgetControllerParams& WCParams);
	//广播初始化值 父类
	UFUNCTION(BlueprintCallable)
	virtual void BroadcastInitializeValues();
	//绑定回调函数到依赖项
	virtual void BindCallbacksToDependencies();
	
	//广播能力信息事件
	UPROPERTY(BlueprintAssignable, Category = "GAS|Message")
	FAbilityInfoSignature AbilityInfoDelegate;

	void BroadcastAbilityInfo();
	
protected:
	//技能能力信息数据表
	UPROPERTY(EditDefaultsOnly,BlueprintReadOnly,Category="Widgets Data")
	TObjectPtr<UAbilityInfo> AbilityInfo;
	//这部分不带Base是UE引擎自带的类，这里面的代码无法更改 仅用于继承读取
	UPROPERTY(BlueprintReadOnly, Category = "WidgetController")
	TObjectPtr<APlayerController> PlayerController;//玩家控制器
	
	UPROPERTY(BlueprintReadOnly, Category = "WidgetController")
	TObjectPtr<APlayerState> PlayerState;//玩家属性状态
	
	UPROPERTY(BlueprintReadOnly, Category = "WidgetController")
	TObjectPtr<UAbilitySystemComponent> AbilitySystemComponent;//玩家能力系统组件
	
	UPROPERTY(BlueprintReadOnly, Category = "WidgetController")
	TObjectPtr<UAttributeSet> AttributeSet;//玩家属性集
	
	//Base是我创建自定义的类 这里面有自定义的代码
	UPROPERTY(BlueprintReadOnly, Category = "WidgetController")
	TObjectPtr<ABasePlayerController> BasePlayerController;//玩家控制器
	
	UPROPERTY(BlueprintReadOnly, Category = "WidgetController")
	TObjectPtr<ABasePlayerState> BasePlayerState;//玩家属性状态
	
	UPROPERTY(BlueprintReadOnly, Category = "WidgetController")
	TObjectPtr<UBaseAbilitySystemComponent> BaseAbilitySystemComponent;//玩家能力系统组件
	
	UPROPERTY(BlueprintReadOnly, Category = "WidgetController")
	TObjectPtr<UBaseAttributeSet> BaseAttributeSet;//玩家属性集

	//获取Base玩家控制器
	ABasePlayerController* GetBasePC();
	//获取Base玩家属性状态
	ABasePlayerState* GetBasePS();
	//获取Base玩家能力系统组件
	UBaseAbilitySystemComponent* GetBaseASC();
	//获取Base玩家属性集
	UBaseAttributeSet* GetBaseAS();
	
};
